package com.john.http.core.convert;

import com.john.http.core.util.DateUtil;
import org.apache.commons.lang3.StringUtils;

/**
 * 〈一句话功能简述〉<br/>
 * 〈功能详细描述〉
 *
 * @author jiangguangtao on 2016/4/28.
 */
public class DateValueConverter implements IValueConverter {
    private String formatter;

    public DateValueConverter(String formatter) {
        if (StringUtils.isBlank(formatter)) {
            this.formatter = DateUtil.DEFAULT_DATE;
        } else {
            this.formatter = formatter;
        }
    }

    @Override
    public String getName() {
        return "日期值转换";
    }

    @Override
    public Object convert(String str) {
        return DateUtil.parse(str, formatter);
    }
}
